#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main()
{
    //while(1)
    //{
    //    //printf("I am a process\n");
    //    //sleep(1);
    //}

    //int a = 0;
    //scanf("%d", &a);
    //printf("%d\n", a);
    
    //模拟僵尸状态
    pid_t id = fork();
    if(id == 0)
    {
      //子进程
      //int cnt = 5;
      //while(cnt--)
      while(1)
      {
        printf("我是子进程,pid: %d\n",getpid());
        sleep(1);
      }
      printf("子进程退出！\n");
      exit(1);
    }
    else
    {
      int cnt = 5;
      while(cnt--)
      {
        //父进程
        printf("我是父进程,pid: %d\n",getpid());
        sleep(1);
      }
      printf("父进程结束！\n");
    }
   
    return 0;
}
